package com.apes.fn.tms.model;

import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.Model;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.jpa.generator.ApesGenerator;
import com.apes.framework.plugin.soe.annotations.State;
import com.apes.framework.plugin.soe.annotations.States;
import com.apes.scm.masterdata.enumeration.model.Enumeration;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;

/**
 * 派车单信息
 * @author yiny
 * 2020.3.9
 */
@Getter
@Setter
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = CarInformation.CONST_TABLE_NAME)
public class CarInformation extends Model {
    public static final String CONST_TABLE_NAME = "TMS_CAR_INFORMATION";

    @Id
    @Column(name = "id")
    @ApesGenerator(code = CONST_TABLE_NAME, name="派车单号")
    @Comment("派车单号")
    private String id;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "chauffeur_id", referencedColumnName = "id")
    @Comment("司机")
    private Chauffeur chauffeurId;

//    @Comment("司机")
//    @Column(name = "chauffeur_id")
//    private Chauffeur chauffeurId;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "vehicle_id", referencedColumnName = "id")
    @Comment("车辆")
    private Vehicle vehicleId;

//    @ManyToOne(fetch = FetchType.LAZY)
//    @JoinColumn(name = "branch_line_id", referencedColumnName = "id")
//    @Comment("线路")
//    private BranchLine branchLineId; // 需要考虑是否有多条线路该用什么类型存储

    @Column(name = "branch_line_id")
    @Comment("线路")
    private String branchLineId;

    @States(name = "状态",
            values = {@State(id="assigned", name = "已指派"),@State(id="departed", name = "已发车"),@State(id="done", name="已完成")})
    @Column(name = "status")
    @Comment("状态")
    private String status;//已发车状态 第一期不使用 待地图GPS功能上线后使用


}
